<template>
  <dialog-editor ref="dialog"></dialog-editor>
</template>

<script>
import DialogEditor from '@/components/DialogEditor'
import dialogMixins from '@/utils/commonDialogMixins'

export default {
  mixins: [dialogMixins],
  components: {DialogEditor},
  data() {
    return {
      dataFormConfig: {
        id: {
          hidden: true
        },
        ticketNo: {
          label: '票号',
          placeholder: '请输入票号'
        },
        carNo: {
          label: '车牌号',
          placeholder: '请输入车牌'
        },
        ingredientId: {
          label: '材料id',
          placeholder: '请输入材料id'
        },
        roughWeight: {
          label: '毛重',
          type: 'number',
          max: 1000,
          default: 0
        },
        suttleWeight: {
          label: '净重',
          type: 'number',
          max: 1000,
          default: 0
        },
        dayTime: {
          label: '日期',
          type: 'date',
          placeholder: '请选择日期'
        },
        checkName: {
          label: '验收人',
          placeholder: '请输入验收人'
        },
        company: {
          label: '公司',
          placeholder: '请输入公司'
        },
        weightMan: {
          label: '司磅人员',
          placeholder: '请输入司磅人员'
        },
        twoWeight: {
          label: '二次过磅',
          type: 'number',
          max: 1000,
          default: 0
        },
        agio: {
          label: '扣水',
          type: 'number',
          max: 1000,
          default: 0
        },
        driverName: {
          label: '司机',
          placeholder: '请输入司机'
        },
        status: {
          label: '状态',
          type: 'switch',
          activeValue: 1,
          inactiveValue: 0,
          default: 1
        }
      }
    }
  },
  methods: {
    init(id) {
      this.dataForm.id = id || 0

      this.$refs.dialog.initDialog({
        dataForm: this.dataForm,
        config: this.dataFormConfig,
        dataRule: this.getNeedDataRule('ticketNo', 'carNo', 'ingredientName', 'roughWeight', 'suttleWeight', 'dayTime', 'checkName', 'company', 'twoWeight', 'agio', 'driverName','status'),
        initApi: 'weightApi/weightManagerInfo',
        saveApi: 'weightApi/saveWeightManager',
        updateApi: 'weightApi/updateWeightManager',
        objectName: 'weightManager'
      })
    }
  }
}
</script>
